
<template>
    <div class="model-form">
        <el-page-header @back="goBack" content="更新提现配置">
        </el-page-header>
        <div class="model-content">
            <el-form ref="ruleForm" :rules="rules" :model="form" label-width="160px">
                <el-row :gutter="10">
    <el-col :span="12">
            <el-form-item label="提现标识"  prop="key">
        <el-input v-model="form.key" name="key">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="配置名称"  prop="name">
        <el-input v-model="form.name" name="name">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="appId"  prop="appId">
        <el-input v-model="form.appId" name="appId">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="商户号"  prop="mchId">
        <el-input v-model="form.mchId" name="mchId">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="商户Key"  prop="mchKey">
        <el-input v-model="form.mchKey" name="mchKey">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="证书路径"  prop="keyPath">
        <el-input v-model="form.keyPath" name="keyPath">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="手续费"  prop="fee">
        <el-input v-model="form.fee" name="fee">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="费率"  prop="rate">
        <el-input v-model="form.rate" name="rate">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="最小金额"  prop="miniMoney">
        <el-input v-model="form.miniMoney" name="miniMoney">
        </el-input>
            </el-form-item>

    </el-col>
    <el-col :span="12">
            <el-form-item label="备注"  prop="note">
        <el-input v-model="form.note" name="note" type="textarea"></el-input>
            </el-form-item>

    </el-col>

                    <el-col :span="22">
                        <el-form-item>
                            <el-button @click="goBack">取消</el-button>
                            <el-button type="primary" @click="updateData">确定</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script>
    import common from "@/mixins/common.js";


    export default {
        name: "cashConfig_update",
        mixins: [common],
        components: {
            
        },
        data() {
            return {
                form: {
                    key: '',
                    name: '',
                    appId: '',
                    mchId: '',
                    mchKey: '',
                    keyPath: '',
                    fee: '',
                    rate: '',
                    miniMoney: '',
                    note: ''                },
                rules: {
                    key: [
                        {required: true, message: '请输入提现标识', trigger: 'blur'}
                    ],
                    name: [
                        {required: true, message: '请输入配置名称', trigger: 'blur'}
                    ],
                    appId: [
                        {required: true, message: '请输入appId', trigger: 'blur'}
                    ],
                    mchId: [
                        {required: true, message: '请输入商户号', trigger: 'blur'}
                    ],
                    mchKey: [
                        {required: true, message: '请输入商户Key', trigger: 'blur'}
                    ],
                    keyPath: [
                        {required: true, message: '请输入证书路径', trigger: 'blur'}
                    ],
                }
            }
        },
        async mounted() {
            let id = this.$route.query.id;
            let data = {};
            data.id = id;
            let res = await this.$http.form("/cashConfig/view", data);
            if (res.code === 200) {
                this.form = res.data;
            }
        },
        methods: {
            async updateData() {
                try {
                    let valid = await this.$refs["ruleForm"].validate();
                    if (!valid) {
                        return;
                    }
                } catch (e) {
                    return;
                }
                await this.updateDataPost();
            },
            async updateDataPost() {
                let res = await this.$http.form("/cashConfig/update", this.form);
                if (res.code !== 200) {
                    this.$message.error(res.msg);
                    return
                }
                this.$message({
                    message: '更新数据成功',
                    type: 'success'
                });
                this.$router.go(-1);
            },

        }
    }


</script>

<style scoped>

</style>